<template>
	<view>
		<view style="width: 100%; margin: 0 auto;background-color: #FFFFFF;">
			<view style="width: 90%; height: 760px; margin: 0 auto;background-color: #FFFFFF;">
				<view style="overflow: hidden;">
					<view style="font-size: 20px;float: left;">{{xwInfo.theme}}</view>
					<view @click="uniShare()">
						<u-icon name="share-square" size="30" style="float: right;margin-top: 2px;"></u-icon>
					</view>
					<u-tag text="详情" plain size="mini" type="warning"
						style="width: 80rpx;margin-top: 5px;float: right;"></u-tag>
				</view>
				<u--text type="info" style="font-size: 14px;" :text="'发布时间：'+aa(xwInfo.jtime)"></u--text>
				<u--text type="info" :text="'发布人：'+xwInfo.jrname"></u--text>
				<view style="margin-top: 5rpx;">
					<image :src="xwInfo.jimage"></image>
				</view>
				<view style="text-indent:24px;margin-top: 10rpx;font-size: 14px;color: #555555;line-height: 25px;">
					{{xwInfo.content}}
				</view>
				<view style="float: left;width: 20px;margin-top: 9rpx;">
					<u-icon name="eye"></u-icon>
				</view>
				<u--text type="info" style="font-size: 14px; float: left; width: 28px;" :text="xwInfo.num"></u--text>
				<view style="">
					<uni-fav :checked="checked" circle="true" class="favBtn" :circle="true" bg-color="#dd524d"
						bg-color-checked="#007aff" fg-color="#ffffff" bgColorChecked="#007aff" @click="onClick" />
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../../../utils/request.js';
	import uniShare1 from '@/uni_modules/uni-share/js_sdk/uni-share.js';
	export default {
		onBackPress({from}) {
			console.log(from);
			if(from=='backbutton'){
				this.$nextTick(function(){
					uniShare1.hide()
				})
				return uniShare1.isShow;
			}
		},
		components: {},
		data() {
			return {
				liste: "",
				eid: "",
				checked: false,
				showUpImg: true,
				jourid: '',
				xwInfo: []
			}
		},
		onLoad(res) {
			this.jourid = res.jourid;
			this.findxwID();
		},
			
		methods: {
			aa(date){
							const dateTime = new Date(date)
							const YY = dateTime.getFullYear()
							const MM =
								dateTime.getMonth() + 1 < 10 ? '0' + (dateTime.getMonth() + 1) : dateTime.getMonth() + 1
							const DD =
								dateTime.getDate() < 10 ? '0' + dateTime.getDate() : dateTime.getDate()
							const hh =
								dateTime.getHours() < 10 ? '0' + dateTime.getHours() : dateTime.getHours()
							const mm =
								dateTime.getMinutes() < 10 ? '0' + dateTime.getMinutes() : dateTime.getMinutes()
							const ss =
								dateTime.getSeconds() < 10 ? '0' + dateTime.getSeconds() : dateTime.getSeconds()
							return `${YY}-${MM}-${DD}`
						},
			// 分享
			uniShare(){
				let that = this
					let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
					let curRoute = routes[routes.length - 1].$page.fullPath // 获取当前页面路由，也就是最后一个打开的页面路由
				uni.share({
						provider: "weixin",
						scene: "WXSceneSession",
						type: 0,
						href:'/index/hjj/xinwen/XinwenInfo',
						title: that.xwInfo.theme,
						summary: that.xwInfo.content,
						// "https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/d8590190-4f28-11eb-b680-7980c8a877b8.png
						imageUrl: "static/lx1.jpg",
						success: function (res) {
							console.log("success:" + JSON.stringify(res));
						},
						fail: function (err) {
							console.log("fail:" + JSON.stringify(err));
						}
				})
			},
			// 收藏
			onClick() {
				var that = this
				this.checked = !this.checked
				if (!this.checked) {
					request({
						url: 'fragmentary/deleteXwSc?jourid='+this.jourid,
						method: 'POST',
						success: (res) => {
							uni.showToast({
								title: "取消收藏"
							})
						}
					})
				} else {
					uni.getStorage({
						key: "user",
						success: function(res) {
							that.liste = res.data
						},
					});
					request({
						url: 'fragmentary/addXwSc',
						data: {
							eid: this.liste.eid,
							jourid: this.jourid
						},
						method: 'POST',
						dataType: 'json',
						success: (res) => {
							console.log("看一下userid", that.liste.eid);
							uni.showToast({
								title: "收藏成功"
							})
						}
					})


				}
			},

			findxwID() {
				request({
					url: 'fragmentary/findxwID?jourid=' + this.jourid,
					method: 'post',
					success: (res) => {
						console.log(res.data)
						this.xwInfo = res.data
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.example-body {
		display: flex;
		padding: 10px 15px;
	}

	/* #ifdef MP-ALIPAY */
	.uni-fav {
		margin-left: 20rpx;
	}

	/* #endif */


	.favBtn {
		margin: 0 20rpx 20rpx 0;
	}


	.example-body-fullWidth {
		padding: 32rpx 0;
	}

	.example-body-first {
		/* #ifndef APP-PLUS-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: flex-start;
	}

	.favBtn-nav {
		// left:-50rpx;
	}
</style>
